package com.yanqu.road.server.cmd.banquet.goodbanquet;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.banquet.CrossBanquetProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.banquet.baifubanquet.CrossGoodBanquetMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.C2_GOOD_BANQUET_OPEN, desc = "开启百福宴")
public class CrossGoodBanquetOpenCmd extends CrossCommand {

    private long userId;
    private int type;
    private int activityId;
    private UserBaseInfo userBaseInfo;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossBanquetProto.GoodBanquetOpenToCrossReqMsg reqMsg = CrossBanquetProto.GoodBanquetOpenToCrossReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        type = reqMsg.getType();
        activityId = reqMsg.getActivityId();
        userBaseInfo = PlayerBasePb.parseToUserBaseInfo(reqMsg.getPlayerBaseData());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        MessageHelper.sendPacket(serverId, userId, YanQuMessageUtils.buildMessage(GameProtocol.S_GOOD_BANQUET_OPEN_FROM_CROSS, CrossGoodBanquetMgr.openGoodBanquet(activityId,userId,type,userBaseInfo)));
    }

    @Override
    public void sendData() {

    }
}
